import { V, Connection } from 'x-engine';
import { Response } from 'express';
import { base64_decode } from 'locutus/php/url';
import { ProxyUser } from '../ml/proxy_user';
import { FindOption, X } from 'x-orm';
import { failed } from '../../../lib/utils';
import { WAP_SITE } from '../../../config';


@V.Controller({
    type : Connection.HTTP,
    url : "/proxy/:method/:code"
})
export class InviteController{
        /**
     * 下级会员邀请码
     */
    async invite(
        res :Response,
        code
    ){
        let id = base64_decode(code);
        let user = await X.of(ProxyUser).findOne(
            id
        );
        if(!user){
            res.sendStatus(404);
            return;
        }
        res.redirect(WAP_SITE + '/wap/?proxy_code=' + code);

        // console.log(code)
        // console.log(123)
    }
}